﻿
using HBase;
using HBase.db;
using System;
using System.Collections.Generic;

namespace hCommand {
    /**
   *┌────────────────────────────────────────────────┐
   *│　描    述：TransferChain                                                    
   *│　作    者：sgj                                              
   *│　版    本：1.0                                              
   *│　创建时间：2020/10/10 9:12:53                        
   *└────────────────────────────────────────────────┘
   **/
    public class Edge :RAM, CacheData {

        public Edge reverseEdge;
        public Node srcNode;
        public Node desNode;
        public int src;
        public int angle;
        public int a;
        public int b;

        public int getTurnRoundTime(int ang) {
            int r = ang - angle;
            if (r < -330) {
                r += 360;
            }
            if (r > 330) {
                r -= 360;
            }
            if (r < 10 && r > -10) {
                return 0;
            } else {
                return 100;
            }


        }
        public int R { get  {
              //Type t=  PathFacade.getType(driveType);
               //object val= t.InvokeMember("getBaseDistance" ,System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public ,null ,null ,new object[] { this });
                return (int)b;
            } }//电阻


        public String driveType;
     
        public int des;

        public Edge(Node src, BStnRelation physical, String driveType, Node des) : 
            this( src, physical.a, physical.b,  driveType,  des) {
          
        }

        public Edge(Node src, int a,int b, String driveType, Node des) {
            this.srcNode = src;
            this.desNode = des;
            this.src = (int)src.getId();
            this.a = a;
            this.b = b;
            this.driveType = driveType;
            this.des = (int)des.getId();
      
            id = src.getId() * 1000000000L + des.getId();
            
            des.addBeforeEdge(this);
            src.getNextEdge().Add(this);

            angle = MyMath.getAngle(des.x-src.x,des.y-src.x);
        }
        public Estimate working() {
            List<Estimate> timeAxis = srcNode.timeAxis;
            for (int i = 0; i < timeAxis.Count; i++) {
                Estimate time = timeAxis[i];
                if (time.taskDto.initStatus <= CoreTaskParamStatus.待执行) {
                    continue;
                }
                Estimate next = time.getNextEstimate();
                if (next.getNode() == desNode) {
                    return next;
                }
                
            }

            return null;
        } 
        
        public Node getSrc() {
            return srcNode;
        }

        public Node getDes() {
            return desNode;
        }


    }
}
